// Copyright (c) Microsoft Corporation. All rights reserved.

#include <windows.h>
#include <tchar.h>

// This program is for debugging the named pipe code in CodeRunnerHelper outside of the remote injection scenario

#define COUNT_OF(x)  (sizeof(x)/sizeof(x[0]))

DWORD RealControlRemoteEnvironment(void);

int _cdecl wmain(int argc, wchar_t* argv[])
{
	wchar_t buf[32768];					 
	wchar_t testVarName[] = L"CR_TEST_VARIABLE";

	::SetEnvironmentVariableW(testVarName, L"123");
	::GetEnvironmentVariableW(testVarName, buf, COUNT_OF(buf));
	 
	wprintf(L"CR_TEST_VARIABLE=%s\n", buf);
	wprintf(L"Named pipe server \\\\.\\pipe\\coderunner$ running.  Run the pipe client now.\n");

	// Call the pipe server code.  This will return when the server terminates.
	RealControlRemoteEnvironment();
	
	::GetEnvironmentVariableW(testVarName, buf, COUNT_OF(buf));
	 
	wprintf(L"CR_TEST_VARIABLE=%s\n", buf);
}
